package com.itfenghuang.day01.day02;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class A07_作业 extends HttpServlet {
    /**
     * 作业
     *   1).注册的功能   注册的页面:账号 密码 确认密码
     *      在Servlet中,获取到请求的参数,如果两次输入的密码不同,
     *      给用户提示密码不相同
     *      如果注册成功,提示注册成功
     *
     *   2).
     *   实现一个Servlet的功能,浏览器访问之后,服务器响应一张图片
     *   给浏览器
     *
     */
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String password1 = req.getParameter("password1");
        String password2 = req.getParameter("password2");

        resp.setContentType("text/html;charset=utf-8");
        PrintWriter writer = resp.getWriter();
        if (password1.equals(password2)){
                writer.write("成功");
            }else {
                writer.write("密码不相同");
            }
        }




    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
